package designMode.factory;

import designMode.factory.method.AliPayFactory;
import designMode.factory.method.PayFactory;
import designMode.factory.method.WechatPayFactory;
import designMode.factory.simple.PaySimpleFactory;

/**
 * @Author 肖地洋
 * @Date 2022/8/13 10:32
 */
public class FactoryMain {

    public static void main(String[] args) {

        // 简单工厂模式
        Pay ali = PaySimpleFactory.creatPay("ali_pay");
        Pay wechat = PaySimpleFactory.creatPay("wechat_pay");
        ali.unifinedPay();
        wechat.unifinedPay();

        // 工厂方法模式
        PayFactory wechatFactory = new WechatPayFactory();
        Pay wechat2 = wechatFactory.getPay();
        wechat2.unifinedPay();

        PayFactory aliFactory = new AliPayFactory();
        Pay alipay2 = aliFactory.getPay();
        alipay2.unifinedPay();
    }
}
